<template>
  <div class="info-cart" v-if="userinfo">
    <div class="wrapper">
      <div class="headImg">
        <van-image
          style="border: 2px solid #fff"
          round
          fit="cover"
          :src="userinfo.headImg"
        >
          <template v-slot:loading>
            <van-loading type="spinner" size="20" />
          </template>
        </van-image>
      </div>
      <div class="username">
        {{ userinfo.username }}
      </div>
    </div>
    <van-grid :border="false" :column-num="3">
      <van-grid-item>
        <div class="focus grid_item">
          <div class="text">关注</div>
          <div class="num">{{ userinfo.followers.length }}</div>
        </div>
      </van-grid-item>
      <van-grid-item>
        <div class="fans grid_item">
          <div class="text">粉丝</div>
          <div class="num">{{ userinfo.fans.length }}</div>
        </div>
      </van-grid-item>
      <van-grid-item>
        <div class="score grid_item">
          <div class="text">积分</div>
          <div class="num">{{ userinfo.score }}</div>
        </div>
      </van-grid-item>
    </van-grid>
  </div>
</template>
<script>
import { reactive, toRefs } from '@vue/reactivity';
import { onBeforeMount } from '@vue/runtime-core';
export default {
  props: ['userinfo'],
  setup(props) {
    const state = reactive({});
    onBeforeMount(() => {
      console.log(props.userinfo);
    });
    return { ...toRefs(state) };
  },
};
</script>
<style lang="less" scoped>
.info-cart {
  margin-top: 20px;
  ::v-deep(.van-grid-item__content) {
    background: none;
  }
  .username {
    font-family: '黑体';
    font-size: 15px;
    padding: 8px 0;
  }
  .grid_item {
    text-align: center;
    .text {
      font-size: 12px;
      font-family: '黑体';
    }
    .num {
      margin-top: 7px;
      font-size: 16px;
      font-weight: 600;
    }
  }
}
.wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  .headImg {
    ::v-deep(.van-image) {
      width: 80px;
      height: 80px;
    }
  }
  .username {
    max-width: 170px;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
  }
}
</style>
